﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CoyoEden.Web.Controls;
using CoyoEden;
using CoyoEden.Models;

public partial class admin_Pages_Communities : AdminBasePage
{
	/// <summary>
	/// Handles the Load event of the Page control.
	/// </summary>
	/// <param name="sender">The source of the event.</param>
	/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!Page.IsPostBack)
		{
			LoadParentDropDown(ddlNewParent);

			//add some js and css
			Utils.AddJavaScriptInclude(Utils.RelativeWebRoot + "assets/js/plugins/flexigrid.js", Page, true);
			Utils.AddStylesheetInclude(Utils.RelativeWebRoot + "assets/css/flexigrid.css", Page, false);
		}
		Page.Title = "社区管理";
	}

	#region helper methods
	private void LoadParentDropDown(DropDownList ddl)
	{
		// Load up the Parent DropDown
		ddl.ClearSelection();
		ddl.Items.Add(new ListItem("none", "-1"));
		foreach (Community c in Community.Communities)
		{
			ddl.Items.Add(new ListItem(c.Name, c.Id.ToString()));
		}
	}
	protected string GetParentName(object item)
	{
		Community temp = (Community)item;
		if (temp.Parent < 0)
			return "";
		else
			return Community.GetCommunity(temp.Parent).Name;
	}
	#endregion
}
